package beans;

import java.util.List;

import dao.Teacher;
import dao.TeacherDAO;

public class Teacherbean {
    private int teacherCounts = -1;
    private TeacherDAO teacherDAO;
    private int pageSize = 5;
    public Teacherbean() {
	teacherDAO = new TeacherDAO();
    }

    public void setTeacherCounts(int teacherCounts) {
	this.teacherCounts = teacherCounts;
    }

    public int getTeacherCounts() {
	if (teacherCounts >= 0){
	    return teacherCounts;
	}
	else {
	    int num = teacherDAO.getTeacherCounts();
	    this.setTeacherCounts(num);
	    return num;
	}
    }
        
    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public List<Teacher> getTeachers(int pageNum){
	return teacherDAO.findTeachers(pageSize, pageNum);
    }

    public List<Teacher> getTeachersByGrade(String grade){
	return teacherDAO.findTeachersByGrade(grade);
    }
    
    public Teacher getTeacherById(String id) {
	return teacherDAO.findById(id);
    }

}
